/**
 * Copyright 2006 Bosco Curtu
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
 * Unless required by applicable law or agreed to in writing, 
 * software distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 * either express or implied. 
 * 
 * See the License for the specific language governing permissions and limitations 
 * under the License.
*/
package com.bcurtu.jobs;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimerTask;

import org.apache.log4j.Logger;

import com.bcurtu.db.AccountDao;
import com.bcurtu.service.TempAliasService;

public class DeleteJob extends TimerTask {

	private Logger log =Logger.getLogger(this.getClass());
	
	private TempAliasService service;
	
	private SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss");
	
	public TempAliasService getService() {
		return service;
	}


	public void setService(TempAliasService service) {
		this.service = service;
	}

	@Override
	public void run() {
		Date date=new Date();
		log.debug("Running DeleteJob"+sdf.format(date));
		int i=service.deleteExpiredAccounts(date);
			
		log.debug("Deleted "+i+" Accounts");
	}
	
	

}
